/**
 * @param {string[]} strs
 * @return {string[][]}
 */
 var groupAnagrams = function(strs, map = new Map()) {
    for (let str of strs) {
        let arr = Array.from(str)
        arr.sort()
        let key = arr.toString()
        let list = map.get(key) ? map.get(key) : new Array()
        list.push(str)
        map.set(key, list) 
    }
    return Array.from(map.values())
};
let res = groupAnagrams(["eat", "tea", "tan", "ate", "nat", "bat"])
console.log(res);